﻿
using Dora.Orm.Core.Domain.Entities;
using Dora.Services.AdminUser.Dto.QueryDto;
using Dora.Services.AdminUser.Entities;
using Dora.Tools.Utility.Const;
using Surging.Core.Common;
using Surging.Core.CPlatform.Ioc;
using Surging.Core.CPlatform.Runtime.Server.Implementation.ServiceDiscovery.Attributes;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Dora.Services.AdminUser.IApplication
{

    /// <summary>
    /// 权限表服务接口
    /// </summary>
    [ServiceBundle("api/" + DoraModuleName.AdminUser + "/{Service}")]
    public interface IPermissionService : IServiceKey
    {

        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "创建")]
        Task<ResultDto<PermissionEntity>> Create(PermissionEntity entity);

        /// <summary>
        /// 根据Id获取一个实体对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "根据Id获取一个实体对象")]
        Task<PermissionEntity> GetById(int id);

        /// <summary>
        /// 分页获取数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "分页获取数据")]
        Task<PageDataList<PermissionEntity>> GetPageList(PermissionQueryDto input);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "修改")]
        Task<ResultDto> Update(PermissionEntity entity);

        /// <summary>
        /// 根据IdList获取列表
        /// </summary>
        /// <param name="idList"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "根据IdList获取列表")]
        Task<List<PermissionEntity>> GetList(List<int> idList);

        /// <summary>
        /// 获取所有
        /// </summary>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "获取所有")]
        Task<List<PermissionEntity>> GetAll();
        
        [Service(Date = "2019-05-05", Director = "TTTan", Name = "通过父级Id获取下级权限")]
        Task<List<PermissionEntity>> GetByParentId(int parentId);


        [Service(Date = "2019-05-05", Director = "TTTan", Name = "更新角色权限")]
        Task<bool> ExistAuthKey(int permissionId, string authKey);

        [Service(Date = "2019-05-05", Director = "TTTan", Name = "导入权限列表")]
        Task<ResultDto<int>> ImportList(List<PermissionEntity> list);

        /// <summary>
        /// 获取员工某个菜单下拥有的所有权限
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="menuId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-05", Director = "TTTan", Name = "获取员工某个菜单下拥有的所有权限")]
        Task<List<PermissionEntity>> GetDoraAuthedListByMenuId(Guid userId, int menuId);

        /// <summary>
        /// 获取Dora用户所有的权限KeyList
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-05", Director = "TTTan", Name = "获取Dora用户所有的权限KeyList")]
        Task<List<string>> GetDoraAuthKeyList(Guid userId);

        /// <summary>
        /// 获取Tas用户所有的权限KeyList
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        [Service(Date = "2019-06-04", Director = "TTTan", Name = "获取Tas用户所有的权限KeyList")]
        Task<List<string>> GetTasAuthKeyList(Guid userId, int orgId);

        /// <summary>
        /// 获取Srm用户所有的权限KeyList
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        [Service(Date = "2019-06-04", Director = "TTTan", Name = "获取Srm用户所有的权限KeyList")]
        Task<List<string>> GetSrmAuthKeyList(Guid userId);

        /// <summary>
        /// 获取用户所有的权限KeyList，根据角色
        /// </summary>
        /// <param name="roleIdList">角色id</param>
        /// <returns></returns>
        [Service(Date = "2019-05-05", Director = "TTTan", Name = "获取用户所有的权限KeyList，根据角色")]
        Task<List<string>> GetDoraAuthKeyListByRoleIdList(List<Guid> roleIdList);
        
        /// <summary>
        /// 通过authkey获取下级所有权限
        /// </summary>
        /// <param name="authKey"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-05", Director = "TTTan", Name = "通过authkey获取下级所有权限")]
        Task<List<PermissionEntity>> GetListByParentAuthKey(string authKey);

        /// <summary>
        /// 通过authkey获取员工某个菜单下拥有的所有权限
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="MenuId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-05", Director = "TTTan", Name = "通过authkey获取员工某个菜单下拥有的所有权限")]
        Task<List<PermissionEntity>> GetDoraAuthedListByParentAuthKey(Guid userId, string authKey);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "删除")]
        Task<ResultDto> Delete(PermissionEntity entity);
    }
}
